package controllayer;

import java.util.ArrayList;
import java.util.Collections;
import modellayer.Salesman;

/**
 * The Class TrackingController.
 *@author Benjamin Ørskov
 *@author Lasse Lambertsen
 *@author Ole Kirk
 *@author Søren Søgaard
 */
public class TrackingController {

	/** The p ctrl. */
	private PersonController pCtrl;

	/**
	 * Instantiates a new tracking controller.
	 */
	public TrackingController() {
		pCtrl = new PersonController();
	}

	/**
	 * Gets the sorted salesman array.
	 *
	 * @return the sorted salesman array
	 */
	public String getSortedSalesmanArray() {
		ArrayList<Salesman> salesmen = pCtrl.getSalesmanArray();
		String returnString = "***Sælgere sorteret efter højeste indtjening***\n";
		Collections.sort(salesmen);
		for (Salesman s : salesmen) {
			returnString += "\n" + s.getName() + "s" + " indtjening:	"
					+ s.getRevenue() + "	DKK.";
		}
		return returnString;
	}

}
